package com.xjcs.saplingplan.room.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.xjcs.saplingplan.room.bean.countdown.PlanCateBean

@Dao
interface PlanCateDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(bean: PlanCateBean)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertList(bean: MutableList<PlanCateBean>)

    @Delete
    fun deleteItem(bean: PlanCateBean)

    @Query("select * from PlanCateBean where planCateUserId = :userId order by planCateSort desc")
    fun getAllPlanCateList(userId: String): MutableList<PlanCateBean>

    @Query("select max(planCateSort) from PlanCateBean where planCateUserId = :userId")
    fun getCateSortMax(userId: String): Int

    @Query("select * from PlanCateBean where planCateName = :cateName")
    fun getPlanCateBean(cateName: String): PlanCateBean?

}